/**
 * 杨辉三角
 */

import java.util.Scanner;


public class YangHuiTriangle {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("请输入杨辉三角的行数:");
        int row = scan.nextInt();
        int[][] yangHuiTri = new int[row][];

        for (int i = 0; i < row; i++) {
            yangHuiTri[i] = new int[i + 1];
            yangHuiTri[i][0] = 1;
            yangHuiTri[i][i] = 1;
            for (int j = 1; j < yangHuiTri[i].length - 1; j++) {
                yangHuiTri[i][j] = yangHuiTri[i - 1][j] + yangHuiTri[i - 1][j - 1];
            }
        }

        for (int i = 0; i < yangHuiTri.length; i++) {
            for (int j = 0; j < yangHuiTri[i].length; j++) {
                System.out.print(yangHuiTri[i][j] + " ");
            }
            System.out.println();
        }
    }
}
